home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / battlera.c < prev    next >
C/C++ Source or Header  |  2000-05-03  |  12KB  |  391 lines

  1. /*******************************************************************************
  2.  
  3.     Battle Rangers                    (c) 1988 Data East Corporation
  4.     Bloody Wolf                        (c) 1988 Data East USA
  5.  
  6.     Emulation by Bryan McPhail, mish@tendril.co.uk
  7.  
  8.     This board is a modified PC-Engine PCB, differences from PC-Engine console:
  9.  
  10.     Input ports are different (2 dips, 2 joysticks, 1 coin port)
  11.     _Interface_ to palette chip is different, palette data is the same.
  12.     Extra sound chips, and extra processor to drive them.
  13.     Twice as much VRAM.
  14.  
  15.     Todo:
  16.         Priority is wrong for the submarine at the end of level 1.
  17.         Music (HuC6280 sound)
  18.  
  19. **********************************************************************/
  20.  
  21. #include "driver.h"
  22. #include "vidhrdw/generic.h"
  23. #include "cpu/h6280/h6280.h"
  24.  
  25. void battlera_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  26. int battlera_vh_start (void);
  27. void battlera_vh_stop (void);
  28. int battlera_interrupt(void);
  29.  
  30. READ_HANDLER( HuC6270_register_r );
  31. WRITE_HANDLER( HuC6270_register_w );
  32. READ_HANDLER( HuC6270_data_r );
  33. WRITE_HANDLER( HuC6270_data_w );
  34. WRITE_HANDLER( battlera_palette_w );
  35.  
  36. READ_HANDLER( HuC6270_debug_r );
  37. WRITE_HANDLER( HuC6270_debug_w );
  38.  
  39. static int control_port_select;
  40.  
  41. /******************************************************************************/
  42.  
  43. static WRITE_HANDLER( battlera_sound_w )
  44. {
  45.     if (offset==0) {
  46.         soundlatch_w(0,data);
  47.         cpu_cause_interrupt(1,H6280_INT_IRQ1);
  48.     }
  49. }
  50.  
  51. /******************************************************************************/
  52.  
  53. static WRITE_HANDLER( control_data_w )
  54. {
  55.     control_port_select=data;
  56. }
  57.  
  58. static READ_HANDLER( control_data_r )
  59. {
  60.     switch (control_port_select) {
  61.         case 0xfe: return readinputport(0); /* Player 1 */
  62.         case 0xfd: return readinputport(1); /* Player 2 */
  63.         case 0xfb: return readinputport(2); /* Coins */
  64.         case 0xf7: return readinputport(4); /* Dip 2 */
  65.         case 0xef: return readinputport(3); /* Dip 1 */
  66.     }
  67.  
  68.     return 0xff;
  69. }
  70.  
  71. /******************************************************************************/
  72.  
  73. static struct MemoryReadAddress battlera_readmem[] =
  74. {
  75.     { 0x000000, 0x0fffff, MRA_ROM },
  76.     { 0x100000, 0x10ffff, HuC6270_debug_r }, /* Cheat to view vram data */
  77.     { 0x1f0000, 0x1f1fff, MRA_BANK8 },
  78.     { 0x1fe000, 0x1fe001, HuC6270_register_r },
  79.     { 0x1ff000, 0x1ff001, control_data_r },
  80.     { -1 }  /* end of table */
  81. };
  82.  
  83. static struct MemoryWriteAddress battlera_writemem[] =
  84. {
  85.     { 0x000000, 0x0fffff, MWA_ROM },
  86.     { 0x100000, 0x10ffff, HuC6270_debug_w }, /* Cheat to edit vram data */
  87.     { 0x1e0800, 0x1e0801, battlera_sound_w },
  88.     { 0x1e1000, 0x1e13ff, battlera_palette_w, &paletteram },
  89.     { 0x1f0000, 0x1f1fff, MWA_BANK8 }, /* Main ram */
  90.     { 0x1fe000, 0x1fe001, HuC6270_register_w },
  91.     { 0x1fe002, 0x1fe003, HuC6270_data_w },
  92.     { 0x1ff000, 0x1ff001, control_data_w },
  93.     { 0x1ff402, 0x1ff403, H6280_irq_status_w },
  94.     { -1 }  /* end of table */
  95. };
  96.  
  97. static struct IOWritePort battlera_portwrite[] =
  98. {
  99.     { 0x00, 0x01, HuC6270_register_w },
  100.     { 0x02, 0x03, HuC6270_data_w },
  101.     { -1 }  /* end of table */
  102. };
  103.  
  104. /******************************************************************************/
  105.  
  106. static WRITE_HANDLER( YM2203_w )
  107. {
  108.     switch (offset) {
  109.     case 0: YM2203_control_port_0_w(0,data); break;
  110.     case 1: YM2203_write_port_0_w(0,data); break;
  111.     }
  112. }
  113.  
  114. static int msm5205next;
  115.  
  116. static void battlera_adpcm_int(int data)
  117. {
  118.     static int toggle;
  119.  
  120.     MSM5205_data_w(0,msm5205next >> 4);
  121.     msm5205next<<=4;
  122.  
  123.     toggle = 1 - toggle;
  124.     if (toggle)
  125.         cpu_cause_interrupt(1,H6280_INT_IRQ2);
  126. }
  127.  
  128. static WRITE_HANDLER( battlera_adpcm_data_w )
  129. {
  130.     msm5205next=data;
  131. }
  132.  
  133. static WRITE_HANDLER( battlera_adpcm_reset_w )
  134. {
  135.     MSM5205_reset_w(0,0);
  136. }
  137.  
  138. static struct MemoryReadAddress sound_readmem[] =
  139. {
  140.     { 0x000000, 0x00ffff, MRA_ROM },
  141.     { 0x1f0000, 0x1f1fff, MRA_BANK7 }, /* Main ram */
  142.     { 0x1ff000, 0x1ff001, soundlatch_r },
  143.     { -1 }  /* end of table */
  144. };
  145.  
  146. static struct MemoryWriteAddress sound_writemem[] =
  147. {
  148.      { 0x000000, 0x00ffff, MWA_ROM },
  149.     { 0x040000, 0x040001, YM2203_w },
  150.     { 0x080000, 0x080001, battlera_adpcm_data_w },
  151.     { 0x1fe800, 0x1fe807, MWA_NOP },
  152.     { 0x1f0000, 0x1f1fff, MWA_BANK7 }, /* Main ram */
  153.     { 0x1ff000, 0x1ff001, battlera_adpcm_reset_w },
  154.     { 0x1ff402, 0x1ff403, H6280_irq_status_w },
  155.     { -1 }  /* end of table */
  156. };
  157.  
  158. /******************************************************************************/
  159.  
  160. INPUT_PORTS_START( battlera )
  161.     PORT_START  /* Player 1 controls */
  162.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  163.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  164.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  165.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  166.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  167.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  168.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  169.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  170.  
  171.     PORT_START  /* Player 2 controls */
  172.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2)
  173.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
  174.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
  175.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  176.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  177.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  178.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  179.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  180.  
  181.     PORT_START    /* Coins */
  182.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  183.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  184.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  185.     PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
  186.  
  187.     PORT_START    /* Dip switch bank 1 */
  188.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  189.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  190.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  191.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  192.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  193.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  195.     PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
  196.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  197.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  198.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
  199.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  200.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  201.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
  202.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  203.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  204.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
  205.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  206.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  207.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
  208.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  209.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  210.  
  211.     PORT_START    /* Dip switch bank 2 */
  212.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  213.     PORT_DIPSETTING(    0x00, "0" )
  214.     PORT_DIPSETTING(    0x01, "1" )
  215.     PORT_DIPSETTING(    0x02, "2" )
  216.     PORT_DIPSETTING(    0x03, "3" )
  217.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
  218.     PORT_DIPSETTING(    0x08, "Easy" )
  219.     PORT_DIPSETTING(    0x0c, "Normal" )
  220.     PORT_DIPSETTING(    0x04, "Hard" )
  221.     PORT_DIPSETTING(    0x00, "Very Hard" )
  222.     PORT_DIPNAME( 0x10, 0x10, "Allow Continue" )
  223.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  224.     PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
  225.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
  226.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  227.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  228.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
  229.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  230.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  231.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
  232.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  233.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  234. INPUT_PORTS_END
  235.  
  236. /******************************************************************************/
  237.  
  238. static struct GfxLayout tiles =
  239. {
  240.     8,8,
  241.     4096,
  242.     4,
  243.     { 16*8, 16*8+8, 0, 8 },
  244.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  245.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  246.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  247.     32*8
  248. };
  249.  
  250. static struct GfxLayout sprites =
  251. {
  252.     16,16,
  253.     1024,
  254.     4,
  255.     { 96*8, 64*8, 32*8, 0 },
  256.     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
  257.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  258.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  259.     128*8
  260. };
  261.  
  262. static struct GfxDecodeInfo gfxdecodeinfo[] =
  263. {
  264.     { REGION_GFX1, 0x00000, &tiles,       0,  16 }, /* Dynamically modified */
  265.     { REGION_GFX1, 0x00000, &sprites,   256,  16 }, /* Dynamically modified */
  266.     { REGION_GFX1, 0x00000, &tiles  ,     0,  16 }, /* Blank tile */
  267.     { -1 } /* end of array */
  268. };
  269.  
  270. /******************************************************************************/
  271.  
  272. static struct YM2203interface ym2203_interface =
  273. {
  274.     1,
  275.     12000000/8, /* 1.5 MHz */
  276.     { YM2203_VOL(40,40) },
  277.     { 0 },
  278.     { 0 },
  279.     { 0 },
  280.     { 0 },
  281.     { 0 },
  282. };
  283.  
  284. static struct MSM5205interface msm5205_interface =
  285. {
  286.     1,                    /* 1 chip             */
  287.     384000,                /* 384KHz             */
  288.     { battlera_adpcm_int },/* interrupt function */
  289.     { MSM5205_S48_4B},    /* 8KHz               */
  290.     { 85 }
  291. };
  292.  
  293. /******************************************************************************/
  294.  
  295. static struct MachineDriver machine_driver_battlera =
  296. {
  297.     /* basic machine hardware */
  298.     {
  299.         {
  300.             CPU_H6280,
  301.             21477200/3,
  302.             battlera_readmem,battlera_writemem,0,battlera_portwrite,
  303.             battlera_interrupt,256 /* 8 prelines, 232 lines, 16 vblank? */
  304.         },
  305.         {
  306.             CPU_H6280 | CPU_AUDIO_CPU,
  307.             21477200/3,
  308.             sound_readmem,sound_writemem,0,0,
  309.             ignore_interrupt,0    /* Interrupts from OPL chip */
  310.         }
  311.     },
  312.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,
  313.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written*/
  314.     0,
  315.  
  316.     /* video hardware */
  317.     32*8, 32*8, { 0*8, 32*8-1, 1*8, 30*8-1 },
  318.  
  319.     gfxdecodeinfo,
  320.     512, 512,
  321.     0,
  322.  
  323.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  324.     0,
  325.     battlera_vh_start,
  326.     battlera_vh_stop,
  327.     battlera_vh_screenrefresh,
  328.  
  329.     /* sound hardware */
  330.     0,0,0,0,
  331.     {
  332.         {
  333.             SOUND_YM2203,
  334.             &ym2203_interface
  335.         },
  336.         {
  337.             SOUND_MSM5205,
  338.             &msm5205_interface
  339.         }
  340.     }
  341. };
  342.  
  343. /******************************************************************************/
  344.  
  345. ROM_START( bldwolf )
  346.     ROM_REGION(0x100000, REGION_CPU1) /* Main cpu code */
  347.     ROM_LOAD( "es00-1.rom", 0x00000, 0x10000, 0xff4aa252 )
  348.     ROM_LOAD( "es01.rom",   0x10000, 0x10000, 0x9fea3189 )
  349.     ROM_LOAD( "es02-1.rom", 0x20000, 0x10000, 0x49792753 )
  350.     /* Rom sockets 0x30000 - 0x70000 are unused */
  351.     ROM_LOAD( "es05.rom",   0x80000, 0x10000, 0x551fa331 )
  352.     ROM_LOAD( "es06.rom",   0x90000, 0x10000, 0xab91aac8 )
  353.     ROM_LOAD( "es07.rom",   0xa0000, 0x10000, 0x8d15a3d0 )
  354.     ROM_LOAD( "es08.rom",   0xb0000, 0x10000, 0x38f06039 )
  355.     ROM_LOAD( "es09.rom",   0xc0000, 0x10000, 0xb718c47d )
  356.     ROM_LOAD( "es10-1.rom", 0xd0000, 0x10000, 0xd3cddc02 )
  357.     /* Rom sockets 0xe0000 - 0x100000 are unused */
  358.  
  359.     ROM_REGION(0x10000, REGION_CPU2) /* Sound CPU */
  360.     ROM_LOAD( "es11.rom",   0x00000, 0x10000, 0xf5b29c9c )
  361.  
  362.     ROM_REGION(0x80000, REGION_GFX1 )
  363.     /* Nothing */
  364. ROM_END
  365.  
  366. ROM_START( battlera )
  367.     ROM_REGION(0x100000, REGION_CPU1) /* Main cpu code */
  368.     ROM_LOAD( "00_e1.bin", 0x00000, 0x10000, 0xaa1cbe69 ) /* ET00 */
  369.     ROM_LOAD( "es01.rom",  0x10000, 0x10000, 0x9fea3189 ) /* ET01 */
  370.     ROM_LOAD( "02_e4.bin", 0x20000, 0x10000, 0xcd72f580 ) /* ET02, etc */
  371.     /* Rom sockets 0x30000 - 0x70000 are unused */
  372.     ROM_LOAD( "es05.rom",  0x80000, 0x10000, 0x551fa331 )
  373.     ROM_LOAD( "es06.rom",  0x90000, 0x10000, 0xab91aac8 )
  374.     ROM_LOAD( "es07.rom",  0xa0000, 0x10000, 0x8d15a3d0 )
  375.     ROM_LOAD( "es08.rom",  0xb0000, 0x10000, 0x38f06039 )
  376.     ROM_LOAD( "es09.rom",  0xc0000, 0x10000, 0xb718c47d )
  377.     ROM_LOAD( "es10-1.rom",0xd0000, 0x10000, 0xd3cddc02 )
  378.     /* Rom sockets 0xe0000 - 0x100000 are unused */
  379.  
  380.     ROM_REGION(0x10000, REGION_CPU2) /* Sound CPU */
  381.     ROM_LOAD( "es11.rom",  0x00000, 0x10000, 0xf5b29c9c )
  382.  
  383.     ROM_REGION(0x80000, REGION_GFX1 )
  384.     /* Nothing */
  385. ROM_END
  386.  
  387. /******************************************************************************/
  388.  
  389. GAMEX( 1988, battlera, 0,        battlera, battlera,  0,   ROT0, "Data East Corporation", "Battle Rangers (World)", GAME_IMPERFECT_SOUND )
  390. GAMEX( 1988, bldwolf,  battlera, battlera, battlera,  0,   ROT0, "Data East USA", "Bloody Wolf (US)", GAME_IMPERFECT_SOUND )
  391.